﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace cludg.Web.Core.RenderHelpers
{
    public static class LoginzaRenderHelper
    {
        public static MvcHtmlString LoginzaLink(this HtmlHelper html, string linkText, string callbackAction)
        {
            return LoginzaLink(html, linkText, callbackAction, null);
        }

        public static MvcHtmlString LoginzaLink(this HtmlHelper html, string linkText, string callbackAction, string callbackController)
        {
            string callbackUrl = 
                UrlHelper.GenerateUrl(
                    null,
                    callbackAction,
                    callbackController,
                    null,
                    html.ViewContext.RequestContext.HttpContext.Request.Url.Host,
                    null,
                    new RouteValueDictionary(),
                    html.RouteCollection,
                    html.ViewContext.RequestContext,
                    true);            
            string link = Utils.LoginzaUtils.GenerateLoginLink(linkText, callbackUrl);
            return MvcHtmlString.Create(link);
        }
    }
}